package br.jus.stf.arquitetura;

import org.apache.tools.ant.taskdefs.LogOutputStream;

import com.vaadin.server.ClassResource;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Component;
import com.vaadin.ui.Embedded;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

@SuppressWarnings("serial")
public abstract class ArquiteturaBase extends UI {

	VaadinRequest request;
	
	/**
	 * O mainlayout é dividido em 3 linhas (barra superior, conteúdo e barra inferior)
	 */
	VerticalLayout mainlayout = new VerticalLayout();

	@Override
	protected final void init(VaadinRequest request) {
		setRequest(request);
		getPage().setTitle(getTitulo());

		mainlayout.setMargin(true);
		mainlayout.setSizeFull();
		
		setContent(mainlayout);
		getContent().setSizeFull();
				
		Embedded logoGIF = new Embedded(null, new ClassResource(this.getClass(), "/imagens/logo.gif"));
		HorizontalLayout barraLogotipo = new HorizontalLayout();
		barraLogotipo.setSizeFull();
		barraLogotipo.addComponent(logoGIF);
		barraLogotipo.setComponentAlignment(logoGIF, Alignment.TOP_LEFT);
		mainlayout.addComponent(barraLogotipo);
		mainlayout.setComponentAlignment(barraLogotipo, Alignment.TOP_LEFT);
		mainlayout.addComponent(initApplicationLayout());
	}

	public abstract Component initApplication();

	private Component initApplicationLayout() {
		return new VerticalLayout();
	}

	public abstract String getTitulo();

	private void setRequest(VaadinRequest request) {
		this.request = request;
	}

	public VaadinRequest getRequest() {
		return request;
	}

}